home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / AccessibleComponent.java < prev    next >
Text File  |  1998-06-30  |  10KB  |  314 lines

  1. /*
  2.  * @(#)AccessibleComponent.java    1.3 98/02/04
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.accessibility;
  22.  
  23. import java.awt.*;
  24. import java.awt.event.*;
  25.  
  26. /**
  27.  * The AccessibleComponent interface should be supported by any object 
  28.  * that is rendered on the screen.  This interface provides the standard 
  29.  * mechanism for an assistive technology to determine and set the 
  30.  * graphical representation of an object.  Applications can determine
  31.  * if an object supports the AccessibleComponent interface by first
  32.  * obtaining its AccessibleContext (see
  33.  * <a href="com.sun.java.accessibility.Accessible.html">Accessible</a>) and
  34.  * then calling the
  35.  * <a href="com.sun.java.accessibility.AccessibleContext.html#getAccessibleComponent">
  36.  * getAccessibleComponent</a> method of AccessibleContext.  If the return 
  37.  * value is not null, the object supports this interface.
  38.  *
  39.  * @see Accessible
  40.  * @see Accessible#getAccessibleContext
  41.  * @see AccessibleContext
  42.  * @see AccessibleContext#getAccessibleComponent
  43.  *
  44.  * @version     1.3 02/04/98 11:12:58
  45.  * @author    Peter Korn
  46.  * @author    Hans Muller
  47.  * @author      Willie Walker
  48.  */
  49. public interface AccessibleComponent {
  50.  
  51.     /**
  52.      * Get the background color of this object.
  53.      *
  54.      * @return the background color, if supported, of the object; 
  55.      * otherwise, null
  56.      * @see #setBackground
  57.      */
  58.     public Color getBackground();
  59.  
  60.     /**
  61.      * Set the background color of this object.
  62.      *
  63.      * @param c the new Color for the background
  64.      * @see #setBackground
  65.      */
  66.     public void setBackground(Color c);
  67.  
  68.     /**
  69.      * Get the foreground color of this object.
  70.      *
  71.      * @return the foreground color, if supported, of the object; 
  72.      * otherwise, null
  73.      * @see #setForeground
  74.      */
  75.     public Color getForeground();
  76.  
  77.     /**
  78.      * Set the foreground color of this object.
  79.      *
  80.      * @param c the new Color for the foreground
  81.      * @see #getForeground
  82.      */
  83.     public void setForeground(Color c);
  84.  
  85.     /**
  86.      * Get the Cursor of this object.
  87.      *
  88.      * @return the Cursor, if supported, of the object; otherwise, null
  89.      * @see #setCursor
  90.      */
  91.     public Cursor getCursor();
  92.  
  93.     /**
  94.      * Set the Cursor of this object.
  95.      *
  96.      * @param c the new Cursor for the object
  97.      * @see #getCursor
  98.      */
  99.     public void setCursor(Cursor cursor);
  100.  
  101.     /**
  102.      * Get the Font of this object.
  103.      *
  104.      * @return the Font,if supported, for the object; otherwise, null
  105.      * @see #setFont
  106.      */
  107.     public Font getFont();
  108.  
  109.     /**
  110.      * Set the Font of this object.
  111.      *
  112.      * @param f the new Font for the object
  113.      * @see #getFont
  114.      */
  115.     public void setFont(Font f);
  116.  
  117.     /**
  118.      * Get the FontMetrics of this object.
  119.      *
  120.      * @param f the Font
  121.      * @return the FontMetrics, if supported, the object; otherwise, null
  122.      * @see #getFont
  123.      */
  124.     public FontMetrics getFontMetrics(Font f);
  125.  
  126.     /**
  127.      * Determine if the object is enabled.  Objects that are enabled
  128.      * will also have the AccessibleState.ENABLED state set in their
  129.      * AccessibleStateSet.
  130.      *
  131.      * @return true if object is enabled; otherwise, false
  132.      * @see #setEnabled
  133.      * @see AccessibleContext#getAccessibleStateSet
  134.      * @see AccessibleState#ENABLED
  135.      * @see AccessibleStateSet
  136.      */
  137.     public boolean isEnabled();
  138.  
  139.     /**
  140.      * Set the enabled state of the object.
  141.      *
  142.      * @param b if true, enables this object; otherwise, disables it 
  143.      * @see #isEnabled
  144.      */
  145.     public void setEnabled(boolean b);
  146.  
  147.     /**
  148.      * Determine if the object is visible.  Note: this means that the
  149.      * object intends to be visible; however, it may not be
  150.      * showing on the screen because one of the objects that this object
  151.      * is contained by is currently not visible.  To determine if an object is
  152.      * showing on the screen, use isShowing().
  153.      * <p>Objects that are visible will also have the 
  154.      * AccessibleState.VISIBLE state set in their AccessibleStateSet.
  155.      *
  156.      * @return true if object is visible; otherwise, false
  157.      * @see #setVisible
  158.      * @see AccessibleContext#getAccessibleStateSet
  159.      * @see AccessibleState#VISIBLE
  160.      * @see AccessibleStateSet
  161.      */
  162.     public boolean isVisible();
  163.  
  164.     /**
  165.      * Set the visible state of the object.
  166.      *
  167.      * @param b if true, shows this object; otherwise, hides it 
  168.      * @see #isVisible
  169.      */
  170.     public void setVisible(boolean b);
  171.  
  172.     /**
  173.      * Determine if the object is showing.  This is determined by checking
  174.      * the visibility of the object and visibility of the object ancestors.
  175.      * Note: this
  176.      * will return true even if the object is obscured by another (for example,
  177.      * it to object is underneath a menu that was pulled down).
  178.      *
  179.      * @return true if object is showing; otherwise, false
  180.      */
  181.     public boolean isShowing();
  182.  
  183.     /** 
  184.      * Checks whether the specified point is within this object's bounds,
  185.      * where the point's x and y coordinates are defined to be relative to the
  186.      * coordinate system of the object. 
  187.      *
  188.      * @param p the Point relative to the coordinate system of the object
  189.      * @return true if object contains Point; otherwise false
  190.      * @see #getBounds
  191.      */
  192.     public boolean contains(Point p);
  193.  
  194.     /** 
  195.      * Returns the location of the object on the screen.
  196.      *
  197.      * @return location of object on screen; null if this object
  198.      * is not on the screen
  199.      * @see #getBounds
  200.      * @see #getLocation
  201.      */
  202.     public Point getLocationOnScreen();
  203.  
  204.     /** 
  205.      * Gets the location of the object relative to the parent in the form 
  206.      * of a point specifying the object's top-left corner in the screen's 
  207.      * coordinate space.
  208.      *
  209.      * @return An instance of Point representing the top-left corner of the 
  210.      * objects's bounds in the coordinate space of the screen; null if
  211.      * this object or its parent are not on the screen
  212.      * @see #getBounds
  213.      * @see #getLocationOnScreen
  214.      */
  215.     public Point getLocation();
  216.  
  217.     /** 
  218.      * Sets the location of the object relative to the parent.
  219.      * @param p the new position for the top-left corner
  220.      * @see #getLocation
  221.      */
  222.     public void setLocation(Point p);
  223.  
  224.     /** 
  225.      * Gets the bounds of this object in the form of a Rectangle object. 
  226.      * The bounds specify this object's width, height, and location
  227.      * relative to its parent. 
  228.      *
  229.      * @return A rectangle indicating this component's bounds; null if 
  230.      * this object is not on the screen.
  231.      * @see #contains
  232.      */
  233.     public Rectangle getBounds();
  234.  
  235.     /** 
  236.      * Sets the bounds of this object in the form of a Rectangle object. 
  237.      * The bounds specify this object's width, height, and location
  238.      * relative to its parent.
  239.      *    
  240.      * @param r rectangle indicating this component's bounds
  241.      * @see #getBounds
  242.      */
  243.     public void setBounds(Rectangle r);
  244.  
  245.     /** 
  246.      * Returns the size of this object in the form of a Dimension object. 
  247.      * The height field of the Dimension object contains this objects's
  248.      * height, and the width field of the Dimension object contains this 
  249.      * object's width. 
  250.      *
  251.      * @return A Dimension object that indicates the size of this component; 
  252.      * null if this object is not on the screen
  253.      * @see #setSize
  254.      */
  255.     public Dimension getSize();
  256.  
  257.     /** 
  258.      * Resizes this object so that it has width and height. 
  259.      *    
  260.      * @param d - The dimension specifying the new size of the object. 
  261.      * @see #getSize
  262.      */
  263.     public void setSize(Dimension d);
  264.  
  265.     /**
  266.      * Returns the Accessible child, if one exists, contained at the local 
  267.      * coordinate Point.
  268.      *
  269.      * @param p The point relative to the coordinate system of this object.
  270.      * @return the Accessible, if it exists, at the specified location; 
  271.      * otherwise null
  272.      */
  273.     public Accessible getAccessibleAt(Point p);
  274.  
  275.     /**
  276.      * Returns whether this object can accept focus or not.   Objects that 
  277.      * can accept focus will also have the AccessibleState.FOCUSABLE state 
  278.      * set in their AccessibleStateSet.
  279.      *
  280.      * @return true if object can accept focus; otherwise false
  281.      * @see AccessibleContext#getAccessibleStateSet
  282.      * @see AccessibleState#FOCUSABLE
  283.      * @see AccessibleState#FOCUSED
  284.      * @see AccessibleStateSet
  285.      */
  286.     public boolean isFocusTraversable();
  287.  
  288.     /**
  289.      * Requests focus for this object.  If this object cannot accept focus,
  290.      * nothing will happen.  Otherwise, the object will attempt to take
  291.      * focus.
  292.      * @see #isFocusTraversable
  293.      */
  294.     public void requestFocus();
  295.  
  296.     /**
  297.      * Adds the specified focus listener to receive focus events from this 
  298.      * component. 
  299.      *
  300.      * @param l the focus listener
  301.      * @see #removeFocusListener
  302.      */
  303.     public void addFocusListener(FocusListener l);
  304.  
  305.     /**
  306.      * Removes the specified focus listener so it no longer receives focus 
  307.      * events from this component.
  308.      *
  309.      * @param l the focus listener
  310.      * @see #addFocusListener
  311.      */
  312.     public void removeFocusListener(FocusListener l);
  313. }
  314.